package utils

import (
	"fmt"
	"reflect"
)

type animalsEnumDef struct {
	Camel, Gorilla, Jaguar, Monkey, Lion int
}

func (c animalsEnumDef) Get(id string) int {
	vo := reflect.ValueOf(c)
	typeVo := vo.Type()

	for i := 0; i < vo.NumField(); i++ {
		if typeVo.Field(i).Name == id {
			return vo.Field(i).Interface().(int)
		}
	}
	return 0
}

var AnimalsEnum = animalsEnumDef{
	Camel:   12,
	Gorilla: 89,
	Jaguar:  91,
	Monkey:  107,
	Lion:    114,
}

func CheckEnum() {
	myAnimal := 12
	animal := AnimalsEnum.Lion
	if myAnimal == animal {
		fmt.Print("\nAnimal is a Lion.")
	} else {
		fmt.Print("\nAnimal is not a Lion.")
	}
}

func GetEnum() {
	animalX := AnimalsEnum.Get("Jaguar")
	fmt.Printf("\nJaguar ID is: %v", animalX)
}
